package com.bodgittandscarper.brokerhmi.view;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.bodgittandscarper.brokerhmi.control.BASControl;
import com.bodgittandscarper.brokerhmi.model.HMIModel;
import com.bodgittandscarper.brokerhmi.model.ObservableEvent;
import com.bodgittandscarper.brokerhmi.model.PropertyListener;

/**
 * View class holding BottomStatus panel elements.
 * 
 * @author Morten Rummelhoff
 *
 */
public class BottomStatusPanel implements PropertyListener {

	private BASControl basControl;
	private HMIModel hmiModel;
	
	private JLabel statusLabel;
	private JPanel statusPanel;
	
	
	public BottomStatusPanel(HMIModel hmiModel, BASControl basControl) {
			
		this.hmiModel = hmiModel;
		this.basControl = basControl;

		createGUI();

		this.hmiModel.addPropertyListener(this);
		
	}
	
	@Override
	public void propertyChanged(ObservableEvent event, Object value) {

		if (event == ObservableEvent.STATUS_TEXT_CHANGED) {
			statusLabel.setText(value+"");
		}
		
	}


	private void createGUI() {
		statusPanel = new JPanel();
		statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));

		statusLabel = new JLabel("");

		statusPanel.add(Box.createHorizontalStrut(4));
		statusPanel.add(statusLabel);
		statusPanel.add(Box.createVerticalStrut(21));

		statusPanel.setBorder(BorderFactory.createLoweredBevelBorder());
	
	}
	
	/**
	 * Gets the presentation of the bottomstatus panel.
	 * 
	 * @return the presentation of the bottomstatus panel
	 */
	public JPanel getPresentation() {
		return statusPanel;
	}
	
}
